package com.wsoft.system.controller;

import com.wsoft.core.exception.Asserts;
import com.wsoft.system.dto.TestDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wsoft.response.ResponsePage;
import com.wsoft.response.ResponseResult;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 功能描述
 *
 * @author: juiet
 * @date: 2024年08月23日 16:58
 */
@RestController
@Tag(name = "测试")
@RequestMapping("/pub/test")
public class TestController {

    @Operation(summary = "测试11112222",description = "测试描述1")
    @ApiResponse(responseCode = "200", description = "OK")
    @PostMapping("/test1")
    public ResponseResult test(@RequestBody @Valid TestDTO dto) {
        List list = new ArrayList<>();
        Map map = new HashMap(16);
        map.put("[code1]","[name1]");
        map.put("[code2]","[name2]");
        list.add(map);
        return ResponseResult.success(list);
    }


    @Operation(summary = "测试2",description = "测试描述2")
    @ApiResponse(responseCode = "200", description = "OK")
    @PostMapping("/test2")
    public ResponsePage test2(@RequestBody @Valid TestDTO dto) {
        List list = new ArrayList<>();
        Map map = new HashMap(16);
        map.put("[code1]","[name1]");
        map.put("[code2]","[name2]");
        list.add(map);
        return ResponsePage.restPage(list);
    }

    @Operation(summary = "测试3",description = "测试描述2")
    @ApiResponse(responseCode = "200", description = "OK")
    @PostMapping("/test3")
    public ResponseResult test3(@RequestBody @Valid TestDTO dto) {
        Asserts.fail("[sys.meg.success]");
        List list = new ArrayList<>();
        Map map = new HashMap(16);
        map.put("[code1]","[name1]");
        map.put("[code2]","[name2]");
        list.add(map);
        return ResponseResult.success(list);
    }

}
